package com.ysd.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ysd.entity.Product;
import com.ysd.service.ProductService;

@Controller
public class ProductController {
	
	@Autowired
	private ProductService productService;
	
	@RequestMapping("getProducts")
	@ResponseBody
	public List<Product> getProducts(Product product) {
		System.out.println(product);
		List<Product> productList = productService.findProducts(product);
		return productList;
	}
	
	@RequestMapping("getProductById")
	@ResponseBody
	public Product getProductById(int id) {
		Product p = productService.findProductById(id);
		System.out.println(p);
		System.out.println(id);
		return p;
	}
}
